package cn.edu.ncu.housinghub.dto.response.house;

import lombok.Data;

import java.util.List;

@Data
public class PageResult<T> {
    private List<T> data;        // 当前页数据
    private Long total;          // 总记录数
    private Integer pageNum;     // 当前页码
    private Integer pageSize;    // 每页大小
    private Integer totalPages;  // 总页数

    public PageResult(List<T> data, Long total, Integer pageNum, Integer pageSize) {
        this.data = data;
        this.total = total;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.totalPages = (int) Math.ceil((double) total / pageSize);
    }
}